;define(function (require) {
	'use strict';
	var d3=require('d3');
	var $=require('jquery');
	var logs=require('plugin/logs');
		require('plugin/superslide');
	
	function app(){}
	app.prototype={
		init:function(){
			logs.log('loaded.');

			var _nav=require('plugin/nav');
			var nav=new _nav('#navbox','#navpoint');
			nav.run();

			var _Gauge=require('plugin/gauge');

			var c1={
				borderColor:'#D6DFEF',
		        innerBorderColor:'#EBF4FA',
		        arrowColor:'#427EC9',
		        startColor:'#6A9AD7',
		        endColor:'#A1D2F0',
		        img:{
		        	width:28,
		        	height:50,
		        	src:'asset/img/icon1.png'
		        },
		        title:'地区生产总值增速'
			};
			var chart1=new _Gauge('#chart-1',9.5, c1);

			var c2={
				borderColor:'#F5E6CD',
		        innerBorderColor:'#FAE5C7',
		        arrowColor:'#E78F00',
		        startColor:'#F09100',
		        endColor:'#EAC400',
		        waveColor:'#EA9F40',
		        img:{
		        	width:43,
		        	height:27,
		        	src:'asset/img/icon2.png'
		        },
		        title:'一般公共预算增速'
			};
			var chart2=new _Gauge('#chart-2',15.0, c2);

			var c3={
				borderColor:'#CBE7F5',
		        innerBorderColor:'#D1E9F6',
		        arrowColor:'#00A8E0',
		        startColor:'#00A8E0',
		        endColor:'#72CD2C',
		        waveColor:'#72CD2C',
		        img:{
		        	width:50,
		        	height:56,
		        	src:'asset/img/icon3.png'
		        },
		        title:'固定资产投资额增速'
			};
			var chart3=new _Gauge('#chart-3',13.3, c3);

			var c4={
				borderColor:'#F5E7E4',
		        innerBorderColor:'#FDD0BB',
		        arrowColor:'#E85800',
		        startColor:'#E85800',
		        endColor:'#F48C70',
		        waveColor:'#E85800',
		        img:{
		        	width:27,
		        	height:38,
		        	src:'asset/img/icon4.png'
		        },
		        title:'社会消费品零售总额'
			};
			var chart4=new _Gauge('#chart-4',9.5, c4);
			var c5={
				borderColor:'#E0EFEB',
		        innerBorderColor:'#CDEEE7',
		        arrowColor:'#009B7F',
		        startColor:'#009B7F',
		        endColor:'#2EB5E5',
		        waveColor:'#2EB5E5',
		        img:{
		        	width:48,
		        	height:36,
		        	src:'asset/img/icon5.png'
		        },
		        title:'进出口总值'
			};
			var chart5=new _Gauge('#chart-5',-2.9,c5);

			var gauges=[chart1,chart2,chart3,chart4,chart5];
			function updateGauges(gauges)
			{
				for(var i=0;i<5;i++)
				{
					var value = getRandomValue();
					gauges[i].update(value);
				}
			}
			
			function getRandomValue()
			{
				var overflow = 0; //10;
				return 0 - overflow + (100 - 0 + overflow*2) *  Math.random();
			}
			setInterval(function(){
				//随机数
				//updateGauges(gauges);
			}, 10000);


			var _timeline=require('plugin/timeline');
			var timer=new _timeline('#timelinebox');
			timer.init({
				startyear:2014,
				startmonth:10,
				endyear:2015,
				endmonth:10,
				step:10,
				interval:1500,
				callback:function(){
					logs.log(this);
					updateGauges(gauges);
				},
				prevbtn:null,
				nextbtn:null,
				idx:7
			});

			var echart=require('echarts');
			var themetw=require('plugin/themetw')
			var option = {
			    tooltip : {
			        trigger: 'axis'
			    },
			    legend: {
			    		show:false,
			        data:['增幅']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			    xAxis : [
			        {
			            type : 'category',
			            data : ['国有','集体','股份合作','股份制','外商及港澳台','其他类型']
			        }
			    ],
			    yAxis : [
			        {
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'增幅',
			            type:'bar',
			            data:[-12.3, -0.4, 6.0, 11.4, 9.2, 10.0],
			            itemStyle:{
			            	normal:{
			            		color:'#29ACE2',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};
			var chartBar = echarts.init(document.getElementById('subchart-1'), themetw);
			chartBar.setOption(option);

			var option = {
			    tooltip : {
			        trigger: 'axis'
			    },
			    legend: {
			    		show:false,
			        data:['增幅']
			    },
			    grid: {
			        borderColor: '#eee'
			        ,borderWidth:0
			        ,x:90
			        ,y:20
			        ,x2:20
			        ,y2:30
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			    yAxis : [
			        {
			            type : 'category',
			            data : ['第一产业','第二产业','第三产业','城乡居民用电']
			        }
			    ],
			    xAxis : [
			        {
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'增幅',
			            type:'bar',
			            data:[10.8, 3.5, 3.6, 4.2, 8.0],
			            itemStyle:{
			            	normal:{
			            		color:'#29ACE2',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};
			var chartBar = echarts.init(document.getElementById('subchart-2'), themetw);
			chartBar.setOption(option);


			var option = {
			    tooltip : {
			        trigger: 'axis'
			    },
			    series : [
		        {
		            name:'个性化仪表盘',
		            type:'gauge',
		            center : ['50%', '50%'],    // 默认全局居中
		            radius : [0, '85%'],
		            startAngle: 180,
		            endAngle : 0,
		            min: -10,                     // 最小值
		            max: 10,                   // 最大值
		            precision: 0,               // 小数精度，默认为0，无小数点
		            splitNumber: 10,             // 分割段数，默认为5
		            axisLine: {            // 坐标轴线
		                show: true,        // 默认显示，属性show控制显示与否
		                lineStyle: {       // 属性lineStyle控制线条样式
		                    color: [[0.6, 'lightgreen'],[0.8, 'orange'],[1, '#ff4500']], 
		                    width: 20
		                }
		            },
		            axisTick: {            // 坐标轴小标记
		                show: true,        // 属性show控制显示与否，默认不显示
		                splitNumber: 5,    // 每份split细分多少段
		                length :8,         // 属性length控制线长
		                lineStyle: {       // 属性lineStyle控制线条样式
		                    color: '#eee',
		                    width: 1,
		                    type: 'solid'
		                }
		            },
		            splitLine: {           // 分隔线
		                show: true,        // 默认显示，属性show控制显示与否
		                length :30,         // 属性length控制线长
		                lineStyle: {       // 属性lineStyle（详见lineStyle）控制线条样式
		                    color: '#eee',
		                    width: 1,
		                    type: 'solid'
		                }
		            },
		            pointer : {
		                length : '80%',
		                width : 8,
		                color : 'auto'
		            },
		            title : {
		                show : true,
		                offsetCenter: ['0%','50%'],       // x, y，单位px
		                textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
		                    color: '#333',
		                    fontSize : 14
		                }
		            },
		            detail : {
		                show : true,
		                backgroundColor: 'rgba(0,0,0,0)',
		                borderWidth: 0,
		                borderColor: '#ccc',
		                width: 100,
		                height: 40,
		                offsetCenter: ['0%','50%'],       // x, y，单位px
		                formatter:'{value}%',
		                textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
		                    color: '#333',
		                    fontSize : 18
		                }
		            },
		            data:[{value: 1.93, name: '失业率'}]
		        }
		    ]
			};
			var chartBar = echarts.init(document.getElementById('subchart-3'), themetw);
			chartBar.setOption(option);

			var option = {
			    tooltip : {
			        trigger: 'axis'
			    },
			    grid: {
			        borderColor: '#eee'
			        ,borderWidth:0
			        ,x:30
			        ,y:30
			        ,x2:50
			        ,y2:40
			    },
			    legend: {
			    		show:false,
			        data:['增幅','总量']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			   	xAxis : [
			        {
			            type : 'category',
			            data : ['2月','3月','4月','5月','6月','7月','8月','9月']
			        }
			    ],
			    yAxis : [
			        {
			        		name:'增幅',
			            type : 'value'
			        },
			        {
			        		name:'总量',
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'增幅',
			            type:'line',
			            data:[11.3,10.4,9.8,9.0,9.1,9.0,8.9,8.8],
			            itemStyle:{
			            	normal:{
			            		color:'#77BA3D',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        },
			        {
			            name:'总量',
			            yAxisIndex: 1,
			            type:'bar',
			            data:[1656.25,1447.0,1250.91,1084.10,897.90,781.09,623.91,373.56].reverse(),
			            itemStyle:{
			            	normal:{
			            		color:'#29ACE2',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};
			var chartBar = echarts.init(document.getElementById('subchart-4'), themetw);
			chartBar.setOption(option);

			var option = {
			    tooltip : {
			        trigger: 'axis'
			    },
			    legend: {
			    		show:false,
			        data:['总量']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			    xAxis : [
			        {
			            type : 'category',
			            data : ['崇川区','港闸区','开发区','通州区','海安县','如东县','启东市','如皋市','海门市']
			        }
			    ],
			    yAxis : [
			        {
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'总量',
			            type:'bar',
			            data:[32.59,29.77,92.43,170.02,148.20,145.29,163.67,142.77,159.23],
			            itemStyle:{
			            	normal:{
			            		color:'#29ACE2',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};
			var chartBar = echarts.init(document.getElementById('subchart-5'), themetw);
			chartBar.setOption(option);

			var option = {
			    tooltip : {
			        trigger: 'axis'
			    },
			    legend: {
			    		show:false,
			        data:['总量']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			    xAxis : [
			        {
			            type : 'category',
			            data : ['2月','3月','4月','5月','6月','7月','8月','9月']
			        }
			    ],
			    yAxis : [
			        {
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'增幅',
			            type:'line',
			            data:[7.3,15.7,14.4,11.9,9.9,9.2,8.7,8.1],
			            itemStyle:{
			            	normal:{
			            		color:'#29ACE2',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		},
			            		areaStyle: {
			            			type: 'default',
			            			color:'rgba(229, 244, 250, 0.5)'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};
			var chartBar = echarts.init(document.getElementById('subchart-6'), themetw);
			chartBar.setOption(option);

			var option = {
			    calculable : false,
			    series : [
			        {
			            name:'访问来源',
			            type:'pie',
			            radius : [40, 60],
			            // for funnel
			            x: '60%',
			            width: '35%',
			            funnelAlign: 'left',
			            max: 100,
			            data:[

			                {value:2.6, name:'渔业\n2.6%'},
			                {value:2.5, name:'农业\n2.5%'},
			                {value:10.9, name:'林业\n10.9%'},
			                {value:12.7, name:'农林\n牧渔\n服务业\n12.7%'},
			                {value:2.9, name:'牧业\n2.9%'},
			            ]
			        }
			    ]
			};
			var chartBar = echarts.init(document.getElementById('subchart-7'));
			chartBar.setOption(option);

			var option = {
			    tooltip : {
			        trigger: 'axis'
			    },
			    legend: {
			    		show:false,
			        data:['总量']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			    xAxis : [
			        {
			            type : 'category',
			            data : ['2月','3月','4月','5月','6月','7月','8月','9月']
			        }
			    ],
			    yAxis : [
			        {
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'增幅',
			            type:'line',
			            data:[-0.1,-0.1,0.1,-0.3,-0.9,-0.8,-1,-0.8],
			            itemStyle:{
			            	normal:{
			            		color:'RGBA(248, 162, 15, 1)',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            		// ,areaStyle: {
			            		// 	type: 'default',
			            		// 	color:'RGBA(248, 162, 15, 0.3)'
			            		// }
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};
			var chartBar = echarts.init(document.getElementById('subchart-8'), themetw);
			chartBar.setOption(option);


			var funcMap={};
			function addFuncMap(name,func,opt){
				funcMap[name]={};
				funcMap[name].func=func;
				funcMap[name].opt=opt;
			}
			/**level 2**/
			var option = {
					color:'#333',
					title:{
						show:true,
						text:'2-9月份固定投资县市区投资额',
						x:'center',
						y:'bottom',
						textStyle:{
							fontSize:'12px',
							fontWeight:'normal',
							color:'#666666'
						}
					},
			    tooltip : {
			        trigger: 'axis'
			    },
			    grid: {
			        borderColor: '#eee'
			        ,borderWidth:0
			        ,x:30
			        ,y:30
			        ,x2:50
			        ,y2:50
			    },
			    legend: {
			    		show:false,
			        data:['增幅','总量']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			   	xAxis : [
			        {
			            type : 'category',
			            data : ['2月','3月','4月','5月','6月','7月','8月','9月']
			        }
			    ],
			    yAxis : [
			        {
			        		name:'增幅',
			            type : 'value'
			        },
			        {
			        		name:'总量',
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'增幅',
			            type:'line',
			            data:[16.2,15.6,14.3,13.0,13.3,13.0,12.8,12.7],
			            itemStyle:{
			            	normal:{
			            		color:'#77BA3D',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        },
			        {
			            name:'总量',
			            yAxisIndex: 1,
			            type:'bar',
			            data:[656.5,1073.4,1431,1688.2,1989.2,1985.15,2323.90,2682.26,3082.06],
			            itemStyle:{
			            	normal:{
			            		color:'#29ACE2',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};

			addFuncMap('leve2-1',function(option){
				var chartBar = echarts.init(document.getElementById('leve2-1'), themetw);
				chartBar.setOption(option);
			},option);

			var option = {
					title:{
						show:true,
						text:'固定投资县市区投资额',
						x:'center',
						y:'bottom',
						textStyle:{
							fontSize:'12px',
							fontWeight:'normal'
						}
					},
			    calculable : false,
			    series : [
			        {
			            name:'固定投资',
			            type:'pie',
			            radius : [40, 60],
			            // for funnel
			            x: '60%',
			            width: '35%',
			            funnelAlign: 'left',
			            max: 100,
			            data:[

			                {value:1227.83, name:'市区\n1227.83亿元'},
			                {value:1804.24, name:'县区\n1804.24亿元'}
			            ]
			        }
			    ]
			};
			addFuncMap('leve2-2',function(option){
				var chartBar = echarts.init(document.getElementById('leve2-2'));
				chartBar.setOption(option);
			},option);

			var option = {
					color:'#333',
					title:{
						show:true,
						text:'固定投资县市区投资额对比',
						x:'center',
						y:'bottom',
						textStyle:{
							fontSize:'12px',
							fontWeight:'normal',
							color:'#666666'
						}
					},
			    tooltip : {
			        trigger: 'axis'
			    },
			    grid: {
			        borderColor: '#eee'
			        ,borderWidth:0
			        ,x:30
			        ,y:30
			        ,x2:50
			        ,y2:50
			    },
			    legend: {
			    		show:false,
			        data:['增幅','总量']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			   	xAxis : [
			        {
			            type : 'category',
			            data : ['崇川区','港闸区','开发区','通州区','海安县','如东县','启东市','如皋市','海门市']
			        }
			    ],
			    yAxis : [
			        {
			        		name:'增幅',
			            type : 'value'
			        },
			        {
			        		name:'总量',
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'增幅',
			            type:'line',
			            data:[6.0,14.2,10.9,14.0,12.7,12.3,12.3,11.3,12.8],
			            itemStyle:{
			            	normal:{
			            		color:'#77BA3D',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        },
			        {
			            name:'总量',
			            yAxisIndex: 1,
			            type:'bar',
			            data:[303.15,211.50,337.81,401.98,354.48,339.32,384.87,339.52,386.05],
			            itemStyle:{
			            	normal:{
			            		color:'RGBA(238, 175, 67, 1)',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};
			$(document).on('click','#chart-3',function(){
				showLevel(2);
				setTimeout(function(){
					funcMap['leve2-1'].func(funcMap['leve2-1'].opt);
				},1000);
				setTimeout(function(){
					funcMap['leve2-2'].func(funcMap['leve2-2'].opt);
				},1500);
				setTimeout(function(){
					funcMap['leve2-3'].func(funcMap['leve2-3'].opt);
				},2000);
			});

			addFuncMap('leve2-3',function(option){
				var chartBar = echarts.init(document.getElementById('leve2-3'), themetw);
				chartBar.setOption(option);
				chartBar.on('click', function (param) {
	          var str = param.name + ":" + param.value;
	          if(param.name=='崇川区'){
	          	showLevel(3);
	          	setTimeout(function(){
								funcMap['leve3-1'].func(funcMap['leve3-1'].opt);
							},1000);
							setTimeout(function(){
								funcMap['leve3-2'].func(funcMap['leve3-2'].opt);
							},1500);
	          }
	      });
			},option);






			/**level 3**/
			var option = {
					color:'#333',
					title:{
						show:true,
						text:'崇川2-9月份固定投资投资额增幅（%）',
						x:'center',
						y:'bottom',
						textStyle:{
							fontSize:'12px',
							fontWeight:'normal',
							color:'#666666'
						}
					},
			    tooltip : {
			        trigger: 'axis'
			    },
			    grid: {
			        borderColor: '#eee'
			        ,borderWidth:0
			        ,x:30
			        ,y:30
			        ,x2:50
			        ,y2:50
			    },
			    legend: {
			    		show:false,
			        data:['增幅']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			   	xAxis : [
			        {
			            type : 'category',
			            data : ['2月','3月','4月','5月','6月','7月','8月','9月']
			        }
			    ],
			    yAxis : [
			        {
			        		name:'增幅',
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'增幅',
			            type:'line',
			            data:[-1.2,-32.1,-22.8,-21.3,-0.4,-2.5,3.1,6.0],
			            itemStyle:{
			            	normal:{
			            		color:'RGBA(238, 175, 67, 1)',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};

			addFuncMap('leve3-2',function(option){
				var chartBar = echarts.init(document.getElementById('leve3-2'), themetw);
				chartBar.setOption(option);
			},option);

			var option = {
					color:'#333',
					title:{
						show:true,
						text:'崇川2-9月份固定投资投资额总量(亿元)',
						x:'center',
						y:'bottom',
						textStyle:{
							fontSize:'12px',
							fontWeight:'normal',
							color:'#666666'
						}
					},
			    tooltip : {
			        trigger: 'axis'
			    },
			    grid: {
			        borderColor: '#eee'
			        ,borderWidth:0
			        ,x:30
			        ,y:30
			        ,x2:50
			        ,y2:50
			    },
			    legend: {
			    		show:false,
			        data:['总量']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			   	xAxis : [
			        {
			            type : 'category',
			            data : ['2月','3月','4月','5月','6月','7月','8月','9月']
			        }
			    ],
			    yAxis : [
			        {
			        		name:'总量',
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'总量',
			            type:'bar',
			            data:[49.32,59.75,96.35,133.45,194.75,215.37,253.29,303.15],
			            itemStyle:{
			            	normal:{
			            		color:'#29ACE2',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};

			addFuncMap('leve3-1',function(option){
				var chartBar = echarts.init(document.getElementById('leve3-1'), themetw);
				chartBar.setOption(option);
			},option);





			/** mode-chart-1 **/
			var option = {
					color:'#333',
					title:{
						show:true,
						text:'2-9月份全社会工业用电量',
						x:'center',
						y:'bottom',
						textStyle:{
							fontSize:'12px',
							fontWeight:'normal',
							color:'#666666'
						}
					},
			    tooltip : {
			        trigger: 'axis'
			    },
			    grid: {
			        borderColor: '#eee'
			        ,borderWidth:0
			        ,x:50
			        ,y:30
			        ,x2:50
			        ,y2:50
			    },
			    legend: {
			    		show:false,
			        data:['总量']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			   	xAxis : [
			        {
			            type : 'category',
			            data : ['2月','3月','4月','5月','6月','7月','8月','9月']
			        }
			    ],
			    yAxis : [
			        {
			        		//name:'总量',
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'总量',
			            type:'bar',
			            data:[1656.25,1447.0,1250.91,1084.10,897.90,781.09,623.91,373.56].reverse(),
			            itemStyle:{
			            	normal:{
			            		color:'#29ACE2',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};
			addFuncMap('mode-chart-1',function(option){
				var chartBar = echarts.init(document.getElementById('mode-chart-1'), themetw);
				chartBar.setOption(option);
				chartBar.on('click', function (param) {
	          funcMap['mode-chart-3'].func(funcMap['mode-chart-3'].opt);
	      });

			},option);
			
			var option = {
					color:'#333',
					title:{
						show:true,
						text:'2-9月份全社会工业用电量增幅(%)',
						x:'center',
						y:'bottom',
						textStyle:{
							fontSize:'12px',
							fontWeight:'normal',
							color:'#666666'
						}
					},
			    tooltip : {
			        trigger: 'axis'
			    },
			    grid: {
			        borderColor: '#eee'
			        ,borderWidth:0
			        ,x:50
			        ,y:30
			        ,x2:50
			        ,y2:50
			    },
			    legend: {
			    		show:false,
			        data:['总量']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			   	xAxis : [
			        {
			            type : 'category',
			            data : ['2月','3月','4月','5月','6月','7月','8月','9月']
			        }
			    ],
			    yAxis : [
			        {
			        		//name:'总量',
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'总量',
			            type:'line',
			            data:[11.3,10.4,9.8,9.0,9.1,9.0,8.9,8.8],
			            itemStyle:{
			            	normal:{
			            		color:'#29ACE2',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};
			addFuncMap('mode-chart-2',function(option){
				var chartBar = echarts.init(document.getElementById('mode-chart-2'), themetw);
				chartBar.setOption(option);
				chartBar.on('click', function (param) {
	          var str = param.name + ":" + param.value;
	          funcMap['mode-chart-3'].func(funcMap['mode-chart-3'].opt);
	      });
			},option);

			var option = {
					color:'#333',
					title:{
						show:true,
						text:'全市2-9月份全社会工业用电量',
						x:'center',
						y:'bottom',
						textStyle:{
							fontSize:'12px',
							fontWeight:'normal',
							color:'#666666'
						}
					},
			    tooltip : {
			        trigger: 'axis'
			    },
			    grid: {
			        borderColor: '#eee'
			        ,borderWidth:0
			        ,x:50
			        ,y:30
			        ,x2:50
			        ,y2:50
			    },
			    legend: {
			    		show:false,
			        data:['总量']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			   	xAxis : [
			        {
			            type : 'category',
			            data : ['崇川区','港闸区','开发区','通州区','海安县','如东县','启东市','如皋市','海门市']
			        }
			    ],
			    yAxis : [
			        {
			        		//name:'总量',
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'总量',
			            type:'bar',
			            data:[7.58,6.21,22.68,20.82,18.96,19.09,10.28,18.65,14.14],
			            itemStyle:{
			            	normal:{
			            		color:'#29ACE2',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};
			addFuncMap('mode-chart-3',function(option){
				var chartBar = echarts.init(document.getElementById('mode-chart-3'), themetw);
				chartBar.setOption(option);
				chartBar.on('click', function (param) {
	          var str = param.name + ":" + param.value;
	          if(param.name=='崇川区'){
	          	funcMap['mode-chart-4'].func(funcMap['mode-chart-4'].opt);
	          }
	      });
			},option);

			var option = {
					color:'#333',
					title:{
						show:true,
						text:'崇川区2-9月份全社会工业用电量增幅',
						x:'center',
						y:'bottom',
						textStyle:{
							fontSize:'12px',
							fontWeight:'normal',
							color:'#666666'
						}
					},
			    tooltip : {
			        trigger: 'axis'
			    },
			    grid: {
			        borderColor: '#eee'
			        ,borderWidth:0
			        ,x:50
			        ,y:30
			        ,x2:50
			        ,y2:50
			    },
			    legend: {
			    		show:false,
			        data:['增幅']
			    },
			    toolbox: {
			        show : false
			    },
			    calculable : true,
			   	xAxis : [
			        {
			            type : 'category',
			            data : ['2月','3月','4月','5月','6月','7月','8月','9月']
			        }
			    ],
			    yAxis : [
			        {
			        		//name:'总量',
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'增幅',
			            type:'bar',
			            data:[4.5,-3.7,-1.5,-4.5,-4.6,-5.6,-1.4,-3.2],
			            itemStyle:{
			            	normal:{
			            		color:'#29ACE2',
			            		barBorderRadius:0,
			            		barBorderWidth:0,
			            		label:{
			            			show:false,
			            			position:'top'
			            		}
			            	}
			            },
			            barWidth: 10
			        }
			    ]
			};
			addFuncMap('mode-chart-4',function(option){
				var chartBar = echarts.init(document.getElementById('mode-chart-4'), themetw);
				chartBar.setOption(option);
			},option);

//			$('.tv-chart-slide .bd li').first().before(
//				$('.tv-chart-slide .bd li').last()
//			);
			$('.tv-chart-slide').slide({
				mainCell:".bd ul",
				effect:"left",
				vis:1,
				defaultIndex:1,
				pnLoop:false
//				,startFun:function(index, page, $slide, $hd, $bd){
//					var $act = $bd.find('li').not('.clone').eq(index);
//					$act.addClass('active').siblings('li').removeClass('active');
//					updateTvGauges(tv_gauges);
//				}
			});
			
			var cOpt_a={
				width:190,
				borderColor:'#D6DFEF',
		        innerBorderColor:'#EBF4FA',
		        arrowColor:'#427EC9',
		        startColor:'#6A9AD7',
		        endColor:'#A1D2F0',
		        img:{
		        	width:28,
		        	height:32,
		        	src:'asset/img/tv-ga-icon1.png'
		        },
		        title:'地区生产总值增长速度(%)'
			};
			var cOpt_b={
				width:190,
				borderColor:'#D6DFEF',
		        innerBorderColor:'#EBF4FA',
		        arrowColor:'#427EC9',
		        startColor:'#6A9AD7',
		        endColor:'#A1D2F0',
		        img:{
		        	width:33,
		        	height:28,
		        	src:'asset/img/tv-ga-icon2.png'
		        },
		        title:'一般公共预算收入增长速度(%)'
			};
			var cOpt_c={
				width:190,
				borderColor:'#D6DFEF',
		        innerBorderColor:'#EBF4FA',
		        arrowColor:'#427EC9',
		        startColor:'#6A9AD7',
		        endColor:'#A1D2F0',
		        img:{
		        	width:50,
		        	height:36,
		        	src:'asset/img/tv-ga-icon3.png'
		        },
		        title:'固定资产增长速度(%)'
			};
			var cOpt_d={
				width:190,
				borderColor:'#D6DFEF',
		        innerBorderColor:'#EBF4FA',
		        arrowColor:'#427EC9',
		        startColor:'#6A9AD7',
		        endColor:'#A1D2F0',
		        img:{
		        	width:44,
		        	height:25,
		        	src:'asset/img/tv-ga-icon4.png'
		        },
		        title:'社会消费品零售总额增速(%)'
			};
			var cOpt_e={
				width:190,
				borderColor:'#D6DFEF',
		        innerBorderColor:'#EBF4FA',
		        arrowColor:'#427EC9',
		        startColor:'#6A9AD7',
		        endColor:'#A1D2F0',
		        img:{
		        	width:51,
		        	height:23,
		        	src:'asset/img/tv-ga-icon5.png'
		        },
		        title:'新批协议利用外资增速(%)'
			};
			
			var tv_gauges = [];
			$('.tv-chart-a').each(function(i,e){
				var chartVal = 9.5;
				var chartObj = new _Gauge('.tv-chart-a:eq('+i+')', chartVal, cOpt_a);
				tv_gauges.push({obj:chartObj,val:chartVal});
			})
			$('.tv-chart-b').each(function(i,e){
				var chartVal = 13.7;
				var chartObj = new _Gauge('.tv-chart-b:eq('+i+')', chartVal, cOpt_b);
				tv_gauges.push({obj:chartObj,val:chartVal});
			})
			$('.tv-chart-c').each(function(i,e){
				var chartVal = 12.7;
				var chartObj = new _Gauge('.tv-chart-c:eq('+i+')', chartVal, cOpt_c);
				tv_gauges.push({obj:chartObj,val:chartVal});
			})
			$('.tv-chart-d').each(function(i,e){
				var chartVal = 9.7;
				var chartObj = new _Gauge('.tv-chart-d:eq('+i+')', chartVal, cOpt_d);
				tv_gauges.push({obj:chartObj,val:chartVal});
			})
			$('.tv-chart-e').each(function(i,e){
				var chartVal = -2.9;
				var chartObj = new _Gauge('.tv-chart-e:eq('+i+')', chartVal, cOpt_e);
				tv_gauges.push({obj:chartObj,val:chartVal});
			})
			
			function updateTvGauges(gauges)
			{
				if(gauges && gauges.length>0){
					$.each(gauges, function(i,e) {
						var value = e.val;
						var chart = e.obj;
						console.log(chart);
						chart.update(value);
					});
				}
			}

			$(document).on('click', '[data-model]', function(event) {
				event.preventDefault();
				var top=$('body').scrollTop();
				/* Act on the event */
				$('.model').addClass('visbile').css({
					height: $('body').height()
				});
				$('.model-cont-warp').addClass('animated fadeInDownBig').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
		      		$(this).removeClass('fadeInDownBig');
	    		}).css({
					top: top+($(window).height())/2
				});
				setTimeout(function(){
					funcMap['mode-chart-1'].func(funcMap['mode-chart-1'].opt);
				},1000);
				setTimeout(function(){
					funcMap['mode-chart-2'].func(funcMap['mode-chart-2'].opt);
				},1500);

			});

			$('.model').on('click','.closebtn',function(event){
				event.preventDefault();
				$('.model-cont-warp').addClass('animated fadeOutDownBig').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
			      $(this).removeClass('animated fadeOutDownBig');
			      $('.model').removeClass('visbile');
		    	});
			});

			function showLevel(lvl){
				$('#leve'+lvl).addClass('animated visbile fadeInDown').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
			      $(this).removeClass('fadeInDown');
		    	});
			}
		}
	};
	return app;
});